<?
//include script to do user auth
include("login/authincludesessions.php");
?>

<html>

<?

include("header.php");
include("drawmap.php");

?>



<script type="text/javascript">

<?
include("includes/plotnodes.php");
?>

//]]>

</script>


<div id="rightpane">
<?

if($session->logged_in)
{
	echo("<a href=\"adduser.php\">Add Node</a>");

	include("includes/auth.php");
	include("includes/dbconnect.php");

//set form variables to current entries in DB

$result = mysql_query("SELECT * FROM nodes",$link);

if (!$result)
{
       echo "You do not own any nodes";
}
else
{
	echo("<h2>Your Nodes</h2>");

	//start table
	echo("<table>");
	echo("<tr><td>ID</td><td>Name</td></tr>");
	while($row = mysql_fetch_array($result))
	{

	//check if this node is owned by current user
	if($session->username == $row['ownerid'])
	{
		//output the actual data
		echo ("<tr><td>". $row['id'] . "</td>\n");
		echo ("<td>". $row['name'] . "</td>\n");
		echo("<td><a href=\"modifyuser.php?searchid=" . $row['id'] . "\">Edit</a></td></tr>\n");
	}

}

//end table
echo("</table>\n");
}

//close off database connection
mysql_close($link);

}

//print out list of all nodes
echo("<h2>Nodelist</h2>");

include("includes/dbconnect.php");

$result = mysql_query("SELECT * FROM nodes",$link);

if (!$result)
{
       echo "No nodes in database";
}
else
{
	//and print out list of all nodes
	//start table
	
	echo("<table>");
	echo("<tr><td>ID</td><td>Name</td></tr>");
	while($row = mysql_fetch_array($result))
	{
		//check if this node is owned by current user
		{
		//output the actual data
		echo ("<tr>");
		echo("<td><a href=\"displaynode.php?id=" . $row['id'] . "\">". $row['id'] . "</a></td>\n");
		echo ("<td>". $row['name'] . "</td>\n");
		echo("</tr>");
		}
	}
	
	//end table
	echo("</table>");
}

?>

</td>
</tr>
</table>

</div>

</body>
</html>